//
//  UIBarButtonitem_Extension.swift
//  weibo-01
//
//  Created by 韩家奇 on 15/11/15.
//  Copyright © 2015年 hanjiaqi. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    /// 遍历构造函数
    ///
    /// - parameter imageName:  图片名
    /// - parameter target:     监听对象
    /// - parameter actionName: 监听图像名
    ///
    /// - returns:UIBarButtonItem
    convenience init(imageName: String, target: AnyObject?, actionName: String?) {
        let button = UIButton(imageName:imageName, backImageName: nil)
        //判断actionName
        if let actionName = actionName {
            button.addTarget(target, action: Selector(actionName), forControlEvents: .TouchUpInside)
        }
        self.init(customView:button)
    }
}